<template>
    <div ref="eCharts" style="height: 100%"> </div>
</template>

<script>
    import BaseCharts from "./BaseCharts";
    export default {
        name: "PieCharts",
        mixins:[BaseCharts],
        mounted(){
            this.$nextTick(function (){
                this.drawPie();
            })
        },
        methods:{
            i18n(name,text,key){
                return this.$ti18(name,text,"charts",key);
            },
            drawPie(){
                var option={
                    color: ['#3c8dff', '#fab34f', '#79c536', '#ff656b', '#7080fa'],
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b}: {c} ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        right: 10,
                        top: 'center',
                        data: [this.i18n('directAccess','直接访问'), this.i18n('emailMarket','邮件营销'), this.i18n('alliance','联盟广告'), this.i18n('videoAD','视频广告'), this.i18n('engine','搜索引擎')]
                    },
                    series: [
                        {
                            name: this.i18n('accessSour','访问来源'),
                            type: 'pie',
                            radius: ['50%', '70%'],
                            center: ['30%', '50%'],
                            avoidLabelOverlap: false,
                            label: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                label: {
                                    show: true,
                                    fontSize: '15',
                                    fontWeight: 'bold'
                                }
                            },
                            labelLine: {
                                show: false
                            },
                            data: [
                                { value: 335, name: this.i18n('directAccess','直接访问') },
                                { value: 310, name: this.i18n('emailMarket','邮件营销') },
                                { value: 234, name: this.i18n('alliance','联盟广告') },
                                { value: 135, name: this.i18n('videoAD','视频广告') },
                                { value: 1548, name: this.i18n('engine','搜索引擎') }
                            ]
                        }
                    ]
                };
                this.drawCharts(option);
            }
        }

    }
</script>

<style scoped>

</style>